#ifndef __LIST_H__
  #define __LIST_H__

#include "node.h"

namespace memory_management {

//! A simple list for instance_manager

/*!
A minimal list implementation for instance_manager.
*/

  template <class T>
  class list {
  private:
    node<T> *head;

    //! assignment operator: not allowed
    list &operator=(const list &l);

    //! copy constructor: not allowed
    list(const list &l);

  public:
    //! returns the head of the list
    node<T> *get_head() const {
      return this->head;
    } // get_head

    //! adds a new element to the begining of the list
    void prepend(node<T> *element) {
      if (element != 0) {
        element->set_next(this->head);
        this->head = element;
      } // if
    } // prepend

    //! releases the whole list
    void release() {
      node<T> *temp;

      while (this->head != 0) {
        temp = head;
        head = head->get_next();

        delete temp;
        temp = 0;
      } // while
    } // release

    //! default constructor
    list() : head(0) {
      // nothing to do
    } // list

    //! destructor (non-virtual: please do not inherit from this class)
    ~list() {
      release();
    } // ~list

  }; // class list

} // namespace memory_management

#endif
